<?php
function Oget_home_slide()
{
	$obj_helper =& get_instance(); 
	$obj_helper->load->database();	
	$str_query	 	=	' SELECT * ';
	$str_query	 	.=	' FROM '.Fget_ap_table('tbanner_images');
	$str_query	 	.=	' WHERE nid is not null ';
	$str_query	 	.=	' AND nstatus = 1 ';
	$str_query	 	.=	' ORDER BY cindex+0 asc';
	$obj_result = $obj_helper->db->query($str_query);  
	return $obj_result->result_array();
}
function Oget_total_sec_news($_str_where,$oder_by,$oder_asc,$nrow_per_page,$ncurrent_page)
	{

		$obj_helper =& get_instance(); 
		$obj_helper->load->database();	
		$str_query = ' SELECT a.*, b.csection_news	as csection_news';
		$str_query .= ' FROM '.Fget_ap_table('tnews').' as a, ';
		$str_query .= '  '.Fget_ap_table('tsection_news').' as b ';
		$str_query .= ' WHERE a.nid is not null ';
		$str_query .= ' AND a.nstatus =	1';
		$str_query .= ' AND a.nid_section_news =b.nid';
		
		$str_query .= $_str_where;
		$str_query .= ' ORDER BY a.nid desc';
		$str_query .= ' LIMIT '.($ncurrent_page-1)*$nrow_per_page.','.$nrow_per_page;
		$obj_result = $obj_helper->db->query($str_query);  
		return $obj_result->result_array();
	}
function Oget_count_sec_news($_str_where)
	{
		$obj_helper =& get_instance(); 
		$obj_helper->load->database();	
		$str_query = ' SELECT a.nid ';
		$str_query .= ' FROM '.Fget_ap_table('tnews').' as a, ';
		$str_query .= '  '.Fget_ap_table('tsection_news').' as b ';
		$str_query .= ' WHERE a.nid is not null ';
		$str_query .= ' AND a.nstatus =	1';
		$str_query .= ' AND a.nid_section_news =b.nid';
		$str_query .= $_str_where;
		$obj_result = $obj_helper->db->query($str_query); 
		return $obj_result->num_rows();
	}
	
function Oget_total_cat_news($_str_where,$oder_by,$oder_asc,$nrow_per_page,$ncurrent_page)
	{

		$obj_helper =& get_instance(); 
		$obj_helper->load->database();	
		$str_query = ' SELECT a.*, b.csection_news	as csection_news, c.ccat_news	as ccat_news';
		$str_query .= ' FROM '.Fget_ap_table('tnews').' as a, ';
		$str_query .= '  '.Fget_ap_table('tsection_news').' as b, ';
		$str_query .= '  '.Fget_ap_table('tcat_news').' as c ';
		$str_query .= ' WHERE a.nid is not null ';
		$str_query .= ' AND a.nstatus =	1';
		$str_query .= ' AND a.nid_section_news =b.nid';
		$str_query .= ' AND a.nid_cat_news =c.nid';		
		$str_query .= $_str_where;
		$str_query .= ' ORDER BY a.nid desc';
		$str_query .= ' LIMIT '.($ncurrent_page-1)*$nrow_per_page.','.$nrow_per_page;
		$obj_result = $obj_helper->db->query($str_query);  
		return $obj_result->result_array();
	}
function Oget_count_cat_news($_str_where)
	{
		$obj_helper =& get_instance(); 
		$obj_helper->load->database();	
		$str_query = ' SELECT a.nid ';
		$str_query .= ' FROM '.Fget_ap_table('tnews').' as a, ';
		$str_query .= '  '.Fget_ap_table('tsection_news').' as b, ';
		$str_query .= '  '.Fget_ap_table('tcat_news').' as c ';
		$str_query .= ' WHERE a.nid is not null ';
		$str_query .= ' AND a.nstatus =	1';
		$str_query .= ' AND a.nid_section_news =b.nid';
		$str_query .= ' AND a.nid_cat_news =c.nid';
		$str_query .= $_str_where;
		$obj_result = $obj_helper->db->query($str_query); 
		return $obj_result->num_rows();
	}
function Oget_tai_tro()
	{
		$obj_helper =& get_instance(); 
		$obj_helper->load->database();	
		$str_query = ' SELECT a.*';
		$str_query .= ' FROM '.Fget_ap_table('tadvertising').' as a ';
		$str_query .= ' WHERE a.nid is not null ';
		$str_query .= ' AND a.cstatus =	1';
		$obj_result = $obj_helper->db->query($str_query); 
		return $obj_result->result_array();
	}
function Bget_total_vistis()
	{
		$total	='0';
		$obj_helper 		=& get_instance();
		$obj_helper->db->where('nid','1');
		$obj_result = $obj_helper->db->get('total_visit');
		$obj_result = $obj_result->row_array();
		$total		= $obj_result['ntotal'];
		return $total;
	}
function Bget_module($nid)
	{
		$total	='0';
		$obj_helper 		=& get_instance();
		$obj_helper->db->where('nid',$nid);
		$obj_result = $obj_helper->db->get('tmodule');
		$obj_result = $obj_result->row_array();
		$total		= $obj_result['cnote'];
		return $total;
	}
				